package top.wshape1.shiziapi.search.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2024-01-21
 */

@Configuration
public class RabbitMqConfig {

    public static final String SHIZIAPI_PROJECT_ELASTIC_EXCHANGE = "shiziapi-project-elastic-exchange";

    public static final String SHIZIAPI_PROJECT_ELASTIC_QUEUE = "shiziapi.project.elastic.queue";

    public static final String SHIZIAPI_PROJECT_ELASTIC_BINDING = "shiziapi.project.elastic.binding";

    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }

    @Bean
    public Exchange projectElasticExchange() {
        return new DirectExchange(SHIZIAPI_PROJECT_ELASTIC_EXCHANGE, true, false);
    }

    @Bean
    public Queue projectElasticQueue() {
        return new Queue(SHIZIAPI_PROJECT_ELASTIC_QUEUE, true, false, false);
    }

    @Bean
    public Binding projectElasticBinding() {
        return new Binding(SHIZIAPI_PROJECT_ELASTIC_QUEUE,
                Binding.DestinationType.QUEUE,
                SHIZIAPI_PROJECT_ELASTIC_EXCHANGE,
                SHIZIAPI_PROJECT_ELASTIC_BINDING,
                null);
    }


}
